package com.xique.park.controller.client.web.service.biz.service.impl;

import com.xique.common.core.web.domain.AjaxResult;
import com.xique.park.controller.client.web.api.IWxClientApi;
import com.xique.park.controller.client.web.service.biz.service.IWxAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class WxAuthServiceImpl implements IWxAuthService {

    @Value("${wx.appid}")
    private String appid;

    @Value("${wx.secret}")
    private String secret;

    @Autowired
    private IWxClientApi wxClientApi;

    @Override
    public AjaxResult wxAuth(String jsCode) {
        Map<String,Object> params = new HashMap<>(2);
        params.put("appid",appid);
        params.put("secret",secret);
        params.put("js_code",jsCode);
        return AjaxResult.success(wxClientApi.wxAuth(params));
    }
}
